import {reqGoodsDetail} from "@/api";
const state ={
    goodsDetail:{}
};

const mutations ={
    GETGOODSDETAIL(state,goodsDetail){
        state.goodsDetail=goodsDetail;
    },

};

const actions ={
    async getGoodsDetail({commit}, skuId){
        let result = await reqGoodsDetail(skuId)
        if(result.code===200){
            commit('GETGOODSDETAIL', result.data)
        }
    }
};

const getters ={

    categoryView: state => {
        return state.goodsDetail.categoryView||{};
    },
    skuInfo: state => {
        return state.goodsDetail.skuInfo||{}
    },
    spuSaleAttrList: state => {
        return state.goodsDetail.spuSaleAttrList||[]
    }
};

export default {
    state,
    mutations,
    actions,
    getters
}